***********************************************************************************
***************** Final Do File to produce all Tables/Figures for *****************
*** Battles and Bargains: Escalation, Commitment, and Negotiations in Civil War ***
******************** Elizabeth J. Menninga & Alyssa K. Prorok *********************
*************************** Analyses Run in Stata v. 15 ***************************
***********************************************************************************

use "BattlesBargains_ISQ_ReplicationData.dta", clear
set more off

**********************
**********************
*** Codebook Notes ***
**********************
**********************

* Main variable battles_escalation is a three category variable.
	* higher values = greater escalation
		* battles_escalation = 0 (de-escalation post-negotiations)
		* battles_escalation = 1 (no change post-negotiations)
		* battles_escalation = 2 (escalation post-negotiations)
		
	* Dummy versions (used in code below to make creating tables easier):
		* battles_escalation1 = de-escalation
		* battles_escalation2 = no change
		* battles_escalation3 = escalation

* for all variants on this variable, higher values always equal more escalation


********************************************
********************************************
*** Descriptive Stats Referenced in Text ***
********************************************
********************************************

*** Dyad-months that experience negotiation (Thomas data)
tab negotiations 

*** Dyads that experience negotiation (Thomas data)
collapse (sum) negotiation, by(dyadid)
tab negotiation

*** Footnote 6: Bivariate relationship between political and battlefield outcomes
use "BattlesBargains_ISQ_ReplicationData.dta", clear
set more off
tab weak_con_last_neg_dum battles_escalation if t==2, chi2 exact

*** Footnote 11: Frequency of third-party intervention
qui logit neg_DV ib0.battles_escalation weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
* Dyad-months that experience third-party intervention
tab thirdparty_involvement if e(sample)
* Dyads that experience third-party intervention at some point
keep if e(sample)
collapse (sum) thirdparty_involvement, by(dyadid dyad_startyr)
tab thirdparty_involvement

*** Number of negotiation spells by dyad 
use "BattlesBargains_ISQ_ReplicationData.dta", clear
set more off
collapse (sum) neg_onset, by(dyadid dyad_startyr)
tab neg_onset if dyad_startyr>1989
sum neg_onset if dyad_startyr>1989 & neg_onset>1

*** Average time between negotiations
use "BattlesBargains_ISQ_ReplicationData.dta", clear
set more off
qui logit neg_DV ib0.battles_escalation weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
sum t if neg_onset==1 & e(sample), d
tab t if neg_onset==1 & e(sample)
	 
*** Number of observations, dyads, countries
qui logit neg_DV ib0.battles_escalation weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
codebook dyadid sidea if e(sample)

*** Dyad-months that experience negotiation onset
tab neg_DV if e(sample)

*** Footnote 17: Avg battles during negotiations v outside negotiations
sum battleonset_monthtotal if negotiations==1 
sum battleonset_monthtotal if negotiations==0 & battles_escalation!=.

corr l2.battleonset_monthtotal battles_escalation if t==2 & e(sample)
	
*** Percent of negotiations that (de-)escalate
tab battles_escalation if e(sample) & t==2

*** Percent of dyad-months that (de-)escalate
tab battles_escalation if e(sample)




*******************************************
*******************************************
*** Figure 1: Time Series for Sudan-NDA ***
*******************************************
*******************************************
gen battles_escalation_plot=battles_escalation if dyadid==645
replace battles_escalation_plot=-.05 if battles_escalation_plot==0
replace battles_escalation_plot=2.05 if battles_escalation_plot==2
graph twoway (tsline battleonset_monthtotal battles_escalation_plot, lcolor(black black) lpattern(longdash solid) cmissing(n n)) if dyadid==645 & date>=460 & date<=500, ///
     xline(472.5, lwidth(9) lc(gs12)) ///
	 xline(471, lc(black) lpattern(dash)) ///
     xline(474, lc(black)) ///
     xline(487.5, lwidth(9) lc(gs12)) ///
	 xline(486, lc(black) lpattern(dash)) ///
     xline(489, lc(black)) ///
	 xtitle(" ") ///
	 ytitle("Number of Battle Onsets" " ") ///
     xlabel(460 "May 1998" 465 "Oct. 1998" 470 "Mar. 1999" 475 "Aug. 1999" 480 "Jan. 2000" 485 "June 2000" 490 "Nov. 2000" 495 "Apr. 2001" 500 "Sept. 2001", angle(45)) ///
     title("Figure 1: Negotiations and (De-)Escalation in the Sudan-NDA Dyad", size(med) span) ///
     subtitle(" ", size(medsmall)) ///
	 graphregion(color(white)) ///
	 legend(off) ///
 	 saving(Sudan-NDA.gph, replace)
	 

	 
********************************************
********************************************
*** Descriptive Stats Referenced in Text ***
********************************************
********************************************

*** Dyad-months with third-party involvement
use "BattlesBargains_ISQ_ReplicationData.dta", clear
set more off
qui logit neg_DV ib0.battles_escalation weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
tab thirdparty_involvement if e(sample)
	 
	 
	 
**********************************
**********************************
*** Table 1: Descriptive Stats ***
**********************************
**********************************
qui logit neg_DV ib0.battles_escalation weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
asdoc sum neg_DV battles_escalation1 battles_escalation2 battles_escalation3 thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t if e(sample) ///
  , title(Table 1: Descriptive Statistics for Key Variables and Controls) ///
  fhc(\b) ///
  label ///
  stat(N min max mean p50 sd) ///
  dec(2) 
  
  
  
  
  
*** Footnote 25: LRT Time-Varying Effects 
logit neg_DV ib0.battles_escalation##c.t ib0.battles_escalation##c.t##c.t ib0.battles_escalation##c.t##c.t##c.t c.t##c.t c.t##c.t##c.t weak_con_last_neg_dum str_centcomm parity groupnum dyad_months 
estimates store m1r1c
logit neg_DV ib0.battles_escalation c.t##c.t c.t##c.t##c.t weak_con_last_neg_dum str_centcomm parity groupnum dyad_months 
estimates store m1r1c2
lrtest m1r1c m1r1c2 
  
  

******************************
******************************
*** Table 2: Main Analyses ***
******************************
******************************
* Model 1, Table 2
logit neg_DV ib0.battles_escalation weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store m1
estat ic
cvauroc neg_DV battles_escalation2 battles_escalation3 weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t t2 t3, fit seed(11235)

* Model 2, Table 2
logit neg_DV ib0.battles_escalation##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store m2
estat ic
cvauroc neg_DV battles_escalation3 battles_escalation2 thirdparty_involvement escalation_thirdparty_re nochange_thirdparty_re weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t t2 t3, fit seed(11235)

* Create Table 2 *
#delimit;
esttab m1 m2 using table2.rtf, replace
  stats(N) cells("b(star fmt(3))" se(par fmt(3))) 
  modelwidth(7) se label nogaps nonotes title(Table 2: Logistic Regression Results) 
  addnote(Note: Standard errors, clustered on dyad ID, in parentheses. *p<0.05.) 
  nonumbers mtitles("Model 1" "Model 2")  
  star(* 0.05) ;
#delimit cr



*******************************************************************
*******************************************************************
*** Figure 2: Predicted Probabilities based on Model 1, Table 2 ***
*******************************************************************
*******************************************************************
qui logit neg_DV ib0.battles_escalation weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
margins battles_escalation, vsquish  
marginsplot, recast(bar) recastci(rcap) ///
  ciopts(lw(medthick) color(black)) ///
  plotopts(barw(.5) color(gs10)) ///
  xmtick(0(1)2) ///
  ylabel(0(.05).15) ///
  xtitle(" ") ///
  xlabel(0 "De-Escalation" 1 "No Change" 2 "Escalation") ///
  ytitle(Predicted Probability of Negotiations) ///
  title("Figure 2: Predicted Probability of Negotiations, Model 1", size(medlarge)) ///
  graphregion(color(white)) ///
  note("Note: 95% Confidence Intervals reported.", size(small)) ///
  saving (Figure2.gph, replace)

  
*******************************************************************
*******************************************************************
*** Figure 3: Predicted Probabilities based on Model 2, Table 2 ***
*******************************************************************
*******************************************************************
qui logit neg_DV ib0.battles_escalation##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
margins, at(battles_escalation=(0 1 2) thirdparty_involvement=(0(1)1)) vsquish

#delimit;
marginsplot, recast(bar) recastci(rcap) 
  ci1opts(lw(medthick) color(black))
  ci2opts(color(none) blcolor(none))
  plot1opts(barw(.5) color(gs9)) 
  plot2opts(barw(.5) blwidth(none)  color(none)) 
  xmtick(0(1)2) 
  ytitle("Predicted Probability of Negotiations" " ") 
  xtitle(" ")
  xlabel(0 "De-Escalation" 1 "No Change" 2 "Escalation", labsize(small)) 
  title(No Third-Party Involvement, size(medlarge)) 
  graphregion(color(white)) 
  legend(off)
  saving (figure3a.gph, replace) ;
#delimit cr

#delimit;
marginsplot, recast(bar) recastci(rcap) 
  ci1opts(color(none) blcolor(none))
  ci2opts(lw(medthick) color(black))
  plot1opts( barw(.5) blwidth(none) color(none)) 
  plot2opts(barw(.5) color(gs12)) 
  xmtick(0(1)2) 
  ytitle("Predicted Probability of Negotiations" " ") 
  xtitle(" ")
  xlabel(0 "De-Escalation" 1 "No Change" 2 "Escalation", labsize(small)) 
  title(Third-Party Involvement, size(medlarge)) 
  graphregion(color(white)) 
  legend(off)
  saving (figure3b.gph, replace) ;
#delimit cr

#delimit;
graph combine figure3a.gph figure3b.gph ,
  col(2)
  title("Figure 3: Predicted Probability of Negotiations, Model 2", size(medlarge))
  subtitle("", size(medsmall))
  graphregion(color(white))
  note("Note: 95% Confidence Intervals reported.", size(small)) 
  saving(Figure3.gph, replace)  ;
#delimit cr


*******************************************************
*******************************************************
*** Figure 4: Change in Probability of Negotiations ***
*******************************************************
*******************************************************
qui logit neg_DV ib0.battles_escalation##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
margins, dydx(battles_escalation) at(thirdparty_involvement=(0(1)1)) vsquish	
#delimit;
marginsplot, recast(bar) recastci(rcap) yline(0, lw(thin)) 
  ci1opts(lw(none) color(none)) 
  ci2opts(lw(thin) color(black)) 
  plot1opts(barw(.75) blwidth(none) color(none)) 
  plot2opts(barw(.75) color(gs9)) 
  xmtick(0(1)1) 
  ylabel(-.1(.05)0.05) 
  ytick(-.1(.05)0.05)
  xlabel(0 "No 3rd Party" 1 "3rd Party Involvement") 
  ytitle("Change in Probability of Negotiations" " ") 
  xtitle(" ") 
  title("Effect of Post-Negotiation (De-)Escalation", size(med) span) 
  subtitle("Conditional on Third-Party Involvement", size(small) span) 
  graphregion(color(white)) 
  legend(off) 
  saving (m2_fdgraph1.gph, replace) ;
  #delimit cr

qui logit neg_DV ib0.battles_escalation##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
margins, dydx(thirdparty_involvement) at(battles_escalation=(0(1)2)) vsquish	
#delimit;
marginsplot, recast(bar) recastci(rcap) yline(0, lw(thin)) 
  ci1opts(lw(thin) color(black)) 
  plot1opts(barw(.75) color(gs10)) 
  xmtick(0(1)1) 
  ylabel(-.05(.05)0.15) 
  ytick(-.05(.05)0.15)
  xlabel(0 "De-Escalation" 1 "No Change" 2 "Escalation") 
  ytitle("Change in Probability of Negotiations" " ") 
  xtitle(" ") 
  title("Effect of Third-Party Involvement", size(med) span) 
  subtitle("Conditional on Post-Negotiation (De-)Escalation", size(small) span) 
  graphregion(color(white)) 
  legend(off) 
  saving (m2_fdgraph2.gph, replace) ;
  #delimit cr

#delimit;
graph combine m2_fdgraph1.gph m2_fdgraph2.gph ,
  col(2)
  title("Figure 4: Change in  Probability of Negotiations", size(med))
  subtitle("", size(medsmall))
  graphregion(color(white))
  note("Note: 95% Confidence Intervals reported.", size(small))
  saving(Figure4.gph, replace)  ;
#delimit cr



*** Footnote 27: Alternative Binning Algorithms
logit neg_DV de_esc_matching weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t c.t##c.t##c.t, cl(dyadid)
cem weak_con_last_neg_dum (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months t if e(sample), treatment(de_esc_matching) autocuts(ss)
cem weak_con_last_neg_dum (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months t if e(sample), treatment(de_esc_matching)
logit neg_DV deesc_no_matching weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t c.t##c.t##c.t, cl(dyadid)
cem weak_con_last_neg_dum (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months t if e(sample), treatment(deesc_no_matching) autocuts(ss)
cem weak_con_last_neg_dum (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months t if e(sample), treatment(deesc_no_matching)
logit neg_DV no_esc_matching weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t c.t##c.t##c.t, cl(dyadid)
cem weak_con_last_neg_dum (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months t if e(sample), treatment(no_esc_matching) autocuts(ss)
cem weak_con_last_neg_dum (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months t if e(sample), treatment(no_esc_matching)



**********************************
**********************************
*** Table 3: Matching Analyses ***
**********************************
**********************************
* Model 1, Table 3 (matching: control=de-escalation; treatment=escalation)
logit neg_DV de_esc_matching weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t, cl(dyadid)
imb weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t if e(sample), treatment(de_esc_matching)
cem weak_con_last_neg_dum (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months t if e(sample), treatment(de_esc_matching) autocuts(fd)
logit neg_DV de_esc_matching dyad_months c.t##c.t##c.t [iweight=cem_weights], cl(dyadid)
estimates store m1t3
	
* Model 2, Table 3 (matching: control=de-escalation; treatment=no change)
logit neg_DV deesc_no_matching weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t, cl(dyadid)
imb weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t if e(sample), treatment(deesc_no_matching)
estimates store imb2_pre
cem weak_con_last_neg_dum (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months t if e(sample), treatment(deesc_no_matching) autocuts(fd) 
logit neg_DV deesc_no_matching dyad_months c.t##c.t##c.t [iweight=cem_weights], cl(dyadid)
estimates store m2t3

* Model 3, Table 3 (matching: control=no change; treatment=escalation)
logit neg_DV no_esc_matching weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
imb weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t if e(sample), treatment(no_esc_matching)
estimates store imb3_pre
cem weak_con_last_neg_dum (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months t if e(sample), treatment(no_esc_matching) autocuts(fd) 
logit neg_DV no_esc_matching dyad_months c.t##c.t##c.t [iweight=cem_weights], cl(dyadid)
estimates store m3t3

* Model 4, Table 3 (matching: control=de-escalation, no third-party; treatment= escalation, no third-party)
logit neg_DV de_esc_matching_nothird weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
imb weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t if e(sample), treatment(de_esc_matching_nothird)
estimates store imb4_pre
cem weak_con_last_neg_dum (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months  t  if e(sample), treatment(de_esc_matching_nothird) autocut(fd)
logit neg_DV de_esc_matching_nothird dyad_months c.t##c.t##c.t [iweight=cem_weights] , cl(dyadid)
estimates store m4t3

* Model 5, Table 3 (matching: control=de-escalation with third-party; treatment= escalation with third-party)
logit neg_DV de_esc_matching_third weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
imb weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t if e(sample), treatment(de_esc_matching_third)
estimates store imb5_pre
cem weak_con_last_neg_dum (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months  t  if e(sample), treatment(de_esc_matching_third) autocut(fd)
logit neg_DV de_esc_matching_third dyad_months c.t##c.t##c.t [iweight=cem_weights] , cl(dyadid)
estimates store m5t3		

* Table 3 *
#delimit;
esttab m1t3 m2t3 m3t3 m4t3 m5t3 using table3.rtf, replace
  stats(N) cells("b(star fmt(3))" se(par fmt(3))) 
  modelwidth(7) se label nogaps nonotes title(Table 3: CEM Matching Results) 
  addnote(Note: Standard errors, clustered on dyad ID, in parentheses. *p<0.05. Variables for which balance was achieved are not included as controls.) 
  nonumbers mtitles("Model 1 Treatment: Escalation Control: De-Escalation" "Model 2 Treatment: No Change Control: De-Escalation" "Model 3 Treatment: Escalation Control: No Change" "Model 4 Treatment: Escalation, No Third-Party Control: De-Escalation, No Third-Party" "Model 5 Treatment: Escalation, Third-Party Control: De-Escalation, Third-Party")  
  star(* 0.05) ;
#delimit cr




*** Footnote 29: matching on Third-party Involvment 
* Model 1, Table 3 (matching: control=de-escalation; treatment=escalation)
logit neg_DV de_esc_matching thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t, cl(dyadid)
imb weak_con_last_neg_dum thirdparty_involvement str_centcomm parity groupnum dyad_months t if e(sample), treatment(de_esc_matching)
cem weak_con_last_neg_dum (#0) thirdparty_involvement (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months t if e(sample), treatment(de_esc_matching) autocuts(fd)
logit neg_DV de_esc_matching dyad_months c.t##c.t##c.t [iweight=cem_weights], cl(dyadid)
* Model 2, Table 3 (matching: control=de-escalation; treatment=no change)
logit neg_DV deesc_no_matching thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t, cl(dyadid)
imb thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t if e(sample), treatment(deesc_no_matching)
cem thirdparty_involvement (#0) weak_con_last_neg_dum (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months t if e(sample), treatment(deesc_no_matching) autocuts(fd) 
logit neg_DV deesc_no_matching dyad_months c.t##c.t##c.t [iweight=cem_weights], cl(dyadid)
* Model 3, Table 3 (matching: control=no change; treatment=escalation)
logit neg_DV no_esc_matching thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
imb thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t if e(sample), treatment(no_esc_matching)
cem thirdparty_involvement weak_con_last_neg_dum (#0) str_centcomm (#0) parity (#0) groupnum (#0) dyad_months t if e(sample), treatment(no_esc_matching) autocuts(fd) 
logit neg_DV no_esc_matching dyad_months c.t##c.t##c.t [iweight=cem_weights], cl(dyadid)

	
	
	




	
		
**********************************************************
**********************************************************
*** Analyses Presented in the Supplemental Information ***
**********************************************************
**********************************************************

*****************
*****************
*** Figure A1 ***
*****************
*****************
collapse (sum) neg_onset, by(dyadid dyad_startyr)
tab neg_onset if dyad_startyr>1989
sum neg_onset if dyad_startyr>1989 & neg_onset>1
twoway histogram neg_onset if dyad_startyr!=1989, ///
	 discrete gap(10) ///
	 freq width(1) bcolor(navy) ///
     ytitle("Frequency") ///
	 xtitle(" " "Number of Negotiations 1989-2009", size(small)) ///
	 xlabel(0(1)16, labsize(small)) ///
     title("Count of Negotiations by Dyad", size(medlarge)) ///
     graphregion(color(white)) ///
	 saving(FigureA1a.gph, replace) ///
	 legend(off)
	 
use "BattlesBargains_ISQ_ReplicationData.dta", clear
qui logit neg_DV ib0.battles_escalation weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
twoway hist t if neg_onset==1 & e(sample), ///
	 freq bcolor(navy) width(1) ///
	 discrete gap(10) ///
     ytitle("Frequency") ///
	 xtitle(" " "Months Since Previous Negotatiations Ended", size(small)) ///
     title("Time Between Negotiations", size(medlarge)) ///
	 xtick(0(6)60) ///
	 xlabel(0(6)60, labsize(small)) ///
     graphregion(color(white))  ///
	 saving(FigureA1b.gph, replace) ///
	 legend(off)

graph combine FigureA1a.gph FigureA1b.gph , ///
  col(2) ///
  title("Figure A1: Frequency Of and Time Between Negotiations", size(medlarge)) ///
  subtitle("", size(medsmall)) ///
  graphregion(color(white)) ///
  saving(FigureA1.gph, replace) 
  

*****************
*****************
*** Figure A2 ***
*****************
*****************
* Number of negotiations by dyad-month
collapse (sum) neg_onset (count) dyadid, by(dyad_months)
gen prop_neg=neg_onset/dyadid
sum
list prop_neg if dyad_months==48

twoway line prop_neg dyad_months, ///
     ytitle("Proportion of Dyads with Negotiations") ///
	 xtitle(" " "Dyad-Month") ///
     title("Negotiations Per Dyad-Month", size(medlarge)) ///
     graphregion(color(white)) ///
	 saving(FigureA2a.gph, replace) ///
	 legend(off)

* Number of negotiations by year
use "BattlesBargains_ISQ_ReplicationData.dta", clear
collapse (sum) neg_onset, by(year)

twoway line neg_onset year, ///
     ytitle("Number of Negotiations") ///
	 xtitle(" " "Year") ///
     title("Negotiations Per Year", size(medlarge)) ///
     graphregion(color(white)) ///
	 saving(FigureA2b.gph, replace) ///
	 legend(off)

graph combine FigureA2a.gph FigureA2b.gph , ///
  col(2) ///
  title("Figure A2: Negotiations Over Time", size(medlarge)) ///
  subtitle("", size(medsmall)) ///
  graphregion(color(white)) ///
  saving(FigureA2.gph, replace)  


**********************************************
**********************************************
*** Figure A3: Imbalance Pre/Post Matching ***
**********************************************
**********************************************
use "BattlesBargains_ISQ_ReplicationData.dta", clear
set more off

* Model 1
matrix imbalance_pre = (0.00049, 1\0.10166, 2\0.06745, 3\0.15251, 4\0.19398, 5\0.21151, 6)
matrix rownames imbalance_pre = "Concessions" "Central_Command" "Parity" "Number_Rebel_Groups" "Conflict_Duration" "Time"

gen graph_label="" if _n==1
replace graph_label="" if _n==2
replace graph_label="" if _n==3
replace graph_label="" if _n==4
replace graph_label="" if _n==5
replace graph_label="" if _n==6

_matplot imbalance_pre, ///
	mlabel(graph_label) ///
	xtitle(" " " ") ///
	xlabel(0(.1).3) ///
	ytitle(" ") ///
	title("Model 1") ///
    subtitle(" ", size(vsmall)) ///
    graphregion(color(white)) ///
    legend(off) ///	
	column(2 1) ///
	yscale(reverse) ///
    ylabel(1 "Concessions" 2 "Central Command" 3 "Parity" 4 "No. Rebel Groups" 5 "Conflict Duration" 6 "Time Since Neg.", angle(horizontal)) ///
	fxsize(100) ///
	saving (m1_imb_pre.gph, replace) 
		
matrix imbalance_post = (0.00000, 1\0.00000, 2\0.00000, 3\0.00000, 4\0.14594, 5\0.01865, 6)
matrix rownames imbalance_post = "Concessions" "Central_Command" "Parity" "Number_Rebel_Groups" "Conflict_Duration" "Time Since Previous Negotiations"

_matplot imbalance_post, ///
	mlabel(graph_label)  ///
	xtitle(" " " ") ///
    xlabel(0(.1).3) ///
	ytitle(" ") ///
    subtitle(" ", size(medsmall)) ///
    graphregion(color(white)) ///
    legend(off) ///
	column(2 1) ///
	yscale(reverse) ///
    ylabel(1 "Concessions" 2 "Central Command" 3 "Parity" 4 "No. Rebel Groups" 5 "Conflict Duration" 6 "Time Since Neg.", angle(horizontal)) ///
	fxsize(100) ///
	saving (m1_imb_post.gph, replace)	
	
* Model 2
matrix imbalance_pre2 = (0.02284, 1\0.15692, 2\0.00974, 3\0.10371, 4\0.24825, 5\0.39332, 6)
matrix rownames imbalance_pre2 = "Concessions" "Central_Command" "Parity" "Number_Rebel_Groups" "Conflict_Duration" "Time"

_matplot imbalance_pre2, ///
	mlabel(graph_label) ///
	xtitle(" " " ") ///
	xlabel(0(.1).4) ///
	ytitle(" ") ///
	title("Model 2") ///
    subtitle(" ", size(vsmall)) ///
    graphregion(color(white)) ///
    legend(off) ///	
	column(2 1) ///
	yscale(reverse) ///
	ylabel(1 " " 2 " " 3 " " 4 " " 5 " " 6 " ") ///
	fxsize(70) ///
	saving (m2_imb_pre.gph, replace) 
	
matrix imbalance_post2 = (0.00000, 1\0.00000, 2\0.00000, 3\0.00000, 4\0.04854, 5\0.23194, 6)
matrix rownames imbalance_post2 = "Concessions" "Central_Command" "Parity" "Number_Rebel_Groups" "Conflict_Duration" "Time Since Previous Negotiations"

_matplot imbalance_post2, ///
	mlabel(graph_label)  ///
	xtitle(" " " ") ///
	xlabel(0(.1).4) ///
	ytitle(" ") ///
    subtitle(" ", size(medsmall)) ///
    graphregion(color(white)) ///
    legend(off) ///
	column(2 1) ///
	yscale(reverse) ///
	ylabel(1 " " 2 " " 3 " " 4 " " 5 " " 6 " ") ///
	fxsize(70) ///
	saving (m2_imb_post.gph, replace)

* Model 3
matrix imbalance_pre3 = (0.02235, 1\0.025859, 2\0.07719, 3\0.21421, 4\0.12263, 5\0.27887, 6)
matrix rownames imbalance_pre3 = "Concessions" "Central_Command" "Parity" "Number_Rebel_Groups" "Conflict_Duration" "Time"

_matplot imbalance_pre3, ///
	mlabel(graph_label) ///
    xtitle(" " "Pre-Matching") ///
	xlabel(0(.1).3) ///
	ytitle(" ") ///
	title("Model 3") ///
    subtitle(" ", size(vsmall)) ///
    graphregion(color(white)) ///
    legend(off) ///	
	column(2 1) ///
	yscale(reverse) ///
	ylabel(1 " " 2 " " 3 " " 4 " " 5 " " 6 " ") ///
	fxsize(70) ///
	saving (m3_imb_pre.gph, replace) 
	
matrix imbalance_post3 = (0.00000, 1\0.00000, 2\0.00000, 3\0.00000, 4\0.13073, 5\0.06944, 6)
matrix rownames imbalance_post3 = "Concessions" "Central_Command" "Parity" "Number_Rebel_Groups" "Conflict_Duration" "Time Since Previous Negotiations"

_matplot imbalance_post3, ///
	mlabel(graph_label)  ///
	xtitle(" " "Post-Matching") ///
	xlabel(0(.1).3) ///
	ytitle(" ") ///
    subtitle(" ", size(medsmall)) ///
    graphregion(color(white)) ///
    legend(off) ///
	column(2 1) ///
	yscale(reverse) ///
	ylabel(1 " " 2 " " 3 " " 4 " " 5 " " 6 " ") ///
	fxsize(70) ///
	saving (m3_imb_post.gph, replace)	
	
* Model 4
matrix imbalance_pre4 = (0.08933, 1\0.22998, 2\0.11128, 3\0.14443, 4\0.18139, 5\0.13748, 6)
matrix rownames imbalance_pre4 = "Concessions" "Central_Command" "Parity" "Number_Rebel_Groups" "Conflict_Duration" "Time"

_matplot imbalance_pre4, ///
	mlabel(graph_label) ///
	xtitle(" " " ") ///
	xlabel(0(.1).3) ///
	ytitle(" ") ///
	title("Model 4") ///
    subtitle(" ", size(vsmall)) ///
    graphregion(color(white)) ///
    legend(off) ///	
	column(2 1) ///
	yscale(reverse) ///
	ylabel(1 " " 2 " " 3 " " 4 " " 5 " " 6 " ") ///
	fxsize(70) ///
	saving (m4_imb_pre.gph, replace) 
	
matrix imbalance_post4 = (0.00000, 1\0, 2\0, 3\0.00000, 4\0.2073, 5\0.0000, 6)
matrix rownames imbalance_post4 = "Concessions" "Central_Command" "Parity" "Number_Rebel_Groups" "Conflict_Duration" "Time Since Previous Negotiations"

_matplot imbalance_post4, ///
	mlabel(graph_label)  ///
	xtitle(" " " ") ///
	xlabel(0(.1).3) ///
	ytitle(" ") ///
    subtitle(" ", size(medsmall)) ///
    graphregion(color(white)) ///
    legend(off) ///
	column(2 1) ///
	yscale(reverse) ///
	ylabel(1 " " 2 " " 3 " " 4 " " 5 " " 6 " ") ///
	fxsize(70) ///
	saving (m4_imb_post.gph, replace)	
	
* Model 5
matrix imbalance_pre5 = (0.02131, 1\0.17237, 2\0.05566, 3\0.21307, 4\0.22437, 5\0.16983, 6)
matrix rownames imbalance_pre5 = "Concessions" "Central_Command" "Parity" "Number_Rebel_Groups" "Conflict_Duration" "Time"

_matplot imbalance_pre5, ///
	mlabel(graph_label) ///
	xtitle(" " " ") ///
	xlabel(0(.1).3) ///
	ytitle(" ") ///
	title("Model 5") ///
    subtitle(" ", size(vsmall)) ///
    graphregion(color(white)) ///
    legend(off) ///	
	column(2 1) ///
	yscale(reverse) ///
	ylabel(1 " " 2 " " 3 " " 4 " " 5 " " 6 " ") ///
	fxsize(70) ///
	saving (m5_imb_pre.gph, replace) 
	
matrix imbalance_post5 = (0.00000, 1\0, 2\0, 3\0.00000, 4\0.08984, 5\0.02865, 6)
matrix rownames imbalance_post5 = "Concessions" "Central_Command" "Parity" "Number_Rebel_Groups" "Conflict_Duration" "Time Since Previous Negotiations"

_matplot imbalance_post5, ///
	mlabel(graph_label)  ///
	xtitle(" " " ") ///
	xlabel(0(.1).3) ///
	ytitle(" ") ///
    subtitle(" ", size(medsmall)) ///
    graphregion(color(white)) ///
    legend(off) ///
	column(2 1) ///
	yscale(reverse) ///
	ylabel(1 " " 2 " " 3 " " 4 " " 5 " " 6 " ") ///
	fxsize(70) ///
	saving (m5_imb_post.gph, replace)
	
graph combine m1_imb_pre.gph m2_imb_pre.gph m3_imb_pre.gph m4_imb_pre.gph m5_imb_pre.gph m1_imb_post.gph m2_imb_post.gph m3_imb_post.gph m4_imb_post.gph m5_imb_post.gph, col(5) ///
  title("Figure A3: Univariate Imbalance Pre- & Post-Matching, Models in Table 3", size(med)) ///
  subtitle(" ", size(small)) ///
  graphregion(color(white)) ///
  imargin(0 0 0 0) ///  
  saving(figureA3.gph, replace)  	
  	
	
*****************************************
*****************************************
*** Figure A4: Predictive Performance ***
*****************************************
*****************************************
use "BattlesBargains_ISQ_ReplicationData.dta", clear
set more off

*Model 1: full model AUC=0.7521
cvauroc neg_DV battles_escalation2 battles_escalation3 weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t t2 t3, fit seed(11235)
*omitting battes_escalation AUC=0.7462
cvauroc neg_DV weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t t2 t3, fit seed(11235)
*omitting weak_con_last_neg_dum AUC=0.7417
cvauroc neg_DV battles_escalation2 battles_escalation3 str_centcomm parity groupnum dyad_months t t2 t3, fit seed(11235)
*omitting str_centcomm AUC=0.7521
cvauroc neg_DV battles_escalation2 battles_escalation3 weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t t2 t3, fit seed(11235)
*omitting parity AUC=0.7421
cvauroc neg_DV battles_escalation2 battles_escalation3 weak_con_last_neg_dum str_centcomm groupnum dyad_months t t2 t3, fit seed(11235)
*omitting groupnum AUC=0.7523
cvauroc neg_DV battles_escalation2 battles_escalation3 weak_con_last_neg_dum str_centcomm parity dyad_months t t2 t3, fit seed(11235)
*omitting dyad_months AUC=0.7564 
cvauroc neg_DV battles_escalation2 battles_escalation3 weak_con_last_neg_dum str_centcomm parity groupnum t t2 t3, fit seed(11235)

*Model 2: full model AUC=0.7767
cvauroc neg_DV battles_escalation3 battles_escalation2 thirdparty_involvement escalation_thirdparty_re nochange_thirdparty_re weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t t2 t3, fit seed(11235)
*omitting battles_escalation##i.thirdparty_involvement AUC=0.7462
cvauroc neg_DV weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t t2 t3, fit seed(11235)
*omitting weak_con_last_neg_dum AUC=0.7732
cvauroc neg_DV battles_escalation3 battles_escalation2 thirdparty_involvement escalation_thirdparty_re nochange_thirdparty_re str_centcomm parity groupnum dyad_months t t2 t3, fit seed(11235)
*omitting str_centcomm AUC=0.7870
cvauroc neg_DV battles_escalation3 battles_escalation2 thirdparty_involvement escalation_thirdparty_re nochange_thirdparty_re weak_con_last_neg_dum parity groupnum dyad_months t t2 t3, fit seed(11235)
*omitting parity AUC=0.7767
cvauroc neg_DV battles_escalation3 battles_escalation2 thirdparty_involvement escalation_thirdparty_re nochange_thirdparty_re weak_con_last_neg_dum str_centcomm groupnum dyad_months t t2 t3, fit seed(11235)
*omitting groupnum AUC=0.7748
cvauroc neg_DV battles_escalation3 battles_escalation2 thirdparty_involvement escalation_thirdparty_re nochange_thirdparty_re weak_con_last_neg_dum str_centcomm parity dyad_months t t2 t3, fit seed(11235)
*omitting dyad_months AUC=0.7813
cvauroc neg_DV battles_escalation3 battles_escalation2 thirdparty_involvement escalation_thirdparty_re nochange_thirdparty_re weak_con_last_neg_dum str_centcomm parity groupnum t t2 t3, fit seed(11235)

* Figure A4: AUC Omitting Each Variable, Based on Models 1 and 2 Table 2 *
matrix aucs_m1 = (0.7462, 1\0.7417, 1\0.7521, 1\0.7421, 1\0.7523, 1\0.7564, 1)
matrix rownames aucs_m1 = "(De-)Escalation" "Concessions" "Central_Command" "Parity" "Number_Rebel_Groups" "Conflict_Duration"

gen graph_label="Post-Negotiation (De-)Escalation" if _n==1
replace graph_label="Prior Concessions" if _n==2
replace graph_label="Strength of Central Command" if _n==3
replace graph_label="Parity" if _n==4
replace graph_label="Number of Rebel Groups" if _n==5
replace graph_label="Conflict Duration (Months)" if _n==6

gen position=12
replace position=6 if _n==3 | _n==2

_matplot aucs_m1, yline(0.7521, ///
	lw(thin)) mlabel(graph_label) mlabv(position) mlabsize(medsmall) mlabcolor(black) ///
	yscale(range(0.74, 0.79)) ///
	ymtick(0.74 (.01) 0.79) ///
	ylabel(0.74 (.01) 0.79) ///
	xlabel(none) ///
    ytitle("Predictive Power (AUC)" " ") ///
    xtitle(" ") ///
    title("Model 1") ///
    subtitle(" ", size(medsmall)) ///
    graphregion(color(white)) ///
    legend(off) ///
	saving (m1_auc.gph, replace) 
	
matrix aucs_m2 = (0.7462, 1\0.7732, 1\0.7870, 1\0.7767, 1\0.7748, 1\0.7813, 1)
matrix rownames aucs_m2 = "(De-)Escalation*ThirdParty_Involvement" "Concessions" "Central_Command" "Parity" "Number_Rebel_Groups" "Conflict_Duration"

gen graph_label2="Post-Negotiation (De-)Escalation*Third-Party" if _n==1
replace graph_label2="Prior Concessions" if _n==2
replace graph_label2="Strength of Central Command" if _n==3
replace graph_label2="Parity" if _n==4
replace graph_label2="Number of Rebel Groups" if _n==5
replace graph_label2="Conflict Duration (Months)" if _n==6

gen position2=12
replace position2=6 if _n==2
replace position2=3 if _n==5

_matplot aucs_m2, yline(0.7767, ///
	lw(thin)) mlabel(graph_label2) mlabv(position2) mlabsize(medsmall) mlabcolor(black) ///
	yscale(range(0.74, 0.79)) ///
	ymtick(0.74 (.01) 0.79) ///
	ylabel(0.74 (.01) 0.79) ///
	xlabel(none) ///
    ytitle(" ") ///
    xtitle(" ") ///
    title("Model 2") ///
    subtitle(" ", size(medsmall)) ///
    graphregion(color(white)) ///
    legend(off) ///
	saving (m2_auc.gph, replace)   

graph combine m1_auc.gph m2_auc.gph, col(2) ///
  title("Figure A4: K-Fold Cross Validation", size(med)) ///
  subtitle("", size(medsmall)) ///
  graphregion(color(white)) ///
  note("Note: Figure depicts the AUC when omitting each variable.", size(small)) ///
  saving(figureA4.gph, replace)  	

drop _fit graph_label position graph_label2 position2

  
  
***********************************************************************
***********************************************************************
*** Table A1: Alternative Post-Negotiation (De-)Escalation Measures ***
***********************************************************************
***********************************************************************
	
* Model 1 (Continuous Battle Onsets Escalation) 
logit neg_DV battles_escalation_continuous weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a1

* Model 2 (Continuous Battle Onsets Escalation & Third-Party Involvement) 
logit neg_DV c.battles_escalation_continuous##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a2

* Model 3 (Categorical Battle Deaths) 
logit neg_DV ib0.deaths_escalation weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a3

* Model 4 (Categorical Battle Deaths & Third-Party Involvement)
logit neg_DV ib0.deaths_escalation##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a4
	
* Model 5 (Continuous Battle Deaths Escalation)
logit neg_DV deaths_escalation_continuousln weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a5

* Model 6 (Continuous Battle Deaths Escalation & Third-Party Involvement)
logit neg_DV c.deaths_escalation_continuousln##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a6

* Table A1 *
#delimit;
esttab a1 a2 a3 a4 a5 a6 using tableA1.rtf, replace
  stats(N) cells("b(star fmt(3))" se(par fmt(3))) 
  modelwidth(7) se label nogaps nonotes title(Table A1: Alternative Post-Negotiation (De-)Escalation Measures) 
  addnote(Note: Standard errors, clustered on dyad ID, in parentheses. +p<0.1, *p<0.05.) 
  nonumbers mtitles("Model 1" "Model 2" "Model 3" "Model 4" "Model 5" "Model 6")  
  star(+ 0.1 * 0.05) ;
#delimit cr
	


**********************************************************
**********************************************************
*** Table A2: Alternative Pre-Negotiation Time Windows ***
**********************************************************
**********************************************************

* Model 1 (4mo pre-negotiation window)
logit neg_DV ib0.battles_escalation_4mo weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a7

* Model 2 (4mo pre-negotiation window & third-party involvement)
logit neg_DV ib0.battles_escalation_4mo##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a8

* Model 3 (5mo pre-negotiation window)
logit neg_DV ib0.battles_escalation_5mo weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a9

* Model 4 (5mo pre-negotiation window & third-party involvement)
logit neg_DV ib0.battles_escalation_5mo##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a10

* Model 5 (6mo pre-negotiation window)
logit neg_DV ib0.battles_escalation_6mo weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a11

* Model 6 (6mo pre-negotiation window & third-party involvement)
logit neg_DV ib0.battles_escalation_6mo##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a12

* Table A2 *
#delimit;
esttab a7 a8 a9 a10 a11 a12 using tableA2.rtf, replace
  stats(N) cells("b(star fmt(3))" se(par fmt(3))) 
  modelwidth(7) se label nogaps nonotes title(Table A2: Alternative Pre-Negotiation Time Windows) 
  addnote(Note: Standard errors, clustered on dyad ID, in parentheses. +p<0.1, *p<0.05.) 
  nonumbers mtitles("4 Mo" "4 Mo" "5 Mo" "5 Mo" "6 Mo" "6 Mo")  
  star(+ 0.1 * 0.05) ;
#delimit cr
	
		
		
***********************************************************************
***********************************************************************
*** Table A3: Alternative Measure with Battle Initiator Information ***
***********************************************************************
***********************************************************************
	
* Model 1 
logit neg_DV ib0.battles_escalation_i weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a13

* Model 2
logit neg_DV ib0.battles_escalation_i##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a14
		
* Table A3 *
#delimit;
esttab a13 a14 using tableA3.rtf, replace
  stats(N) cells("b(star fmt(3))" se(par fmt(3))) 
  modelwidth(7) se label nogaps nonotes title(Table A3: (De-)Escalation: Battle Initiator) 
  addnote(Note: Standard errors, clustered on dyad ID, in parentheses. +p<0.1, *p<0.05.) 
  nonumbers mtitles("Model 1" "Model 2")  
  star(+ 0.1 * 0.05) ;
#delimit cr


	
***************************************************************
***************************************************************
*** Table A4: Alternative Measures of 3rd Party Involvement ***
***************************************************************
***************************************************************
		
* Model 1 (strong involvement) 
logit neg_DV ib0.battles_escalation##i.thirdparty_involvement_strong weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a15

* Model 2 (Mediation)
logit neg_DV ib0.battles_escalation##i.thirdparty_involvement_mediate weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a16

* Model 3 (Security Guarantees) 
logit neg_DV ib0.battles_escalation##i.thirdparty_involvement_enforce weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store a17

* Table A4 *
#delimit;
esttab a15 a16 a17 using tableA4.rtf, replace
  stats(N) cells("b(star fmt(3))" se(par fmt(3))) 
  modelwidth(7) se label nogaps nonotes title(Table A4: Alternative Third-Party Measures) 
  addnote(Note: Standard errors, clustered on dyad ID, in parentheses. +p<0.1, *p<0.05.) 
  nonumbers mtitles("Strong Involvement" "Mediation" "Security Guarantees")  
  star(+ 0.1 * 0.05) ;
#delimit cr
	


****************************************************************************
****************************************************************************
*** Table A5: Alternative Measures of Political Outcomes of Negotiations ***	
****************************************************************************
****************************************************************************
	
* Model 1 (strong concessions)
logit neg_DV ib0.battles_escalation strong_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store p1

* Model 2 (strong concessions & third party involvement)
logit neg_DV ib0.battles_escalation##i.thirdparty_involvement strong_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates stor p2

* Model 3 (political concessions)
logit neg_DV ib0.battles_escalation pol_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store p3

* Model 4 (political concessions & third party involvement)
logit neg_DV ib0.battles_escalation##i.thirdparty_involvement pol_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store p4

* Model 5 (number of concessions)
logit neg_DV ib0.battles_escalation weak_con_last_neg str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store p5

* Model 6 (number of concessions & third party involvement)
logit neg_DV ib0.battles_escalation##i.thirdparty_involvement weak_con_last_neg str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store p6

* Model 7 (change in demands trichotomous)
logit neg_DV ib0.battles_escalation i.change_in_demands_tri str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store p7

* Model 8 (change in demands trichotomous & third party involvement)
logit neg_DV ib0.battles_escalation##i.thirdparty_involvement i.change_in_demands_tri str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store p8

* Model 9 (concessions/demands during last negotiations)
logit neg_DV ib0.battles_escalation ib1.con_rate_4cat str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store p9

* Model 10 (concessions/demands during last negotiations)
logit neg_DV ib0.battles_escalation##i.thirdparty_involvement ib1.con_rate_4cat str_centcomm parity groupnum dyad_months c.t##c.t##c.t , cl(dyadid)
estimates store p10

* Table A5 *
#delimit;
esttab p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 using tableA5.rtf, replace
  stats(N) cells("b(star fmt(3))" se(par fmt(3))) 
  modelwidth(7) se label nogaps nonotes title(Table A5: Alternative Political Outcome of Negotiations Measures) 
  addnote(Note: Standard errors, clustered on dyad ID, in parentheses. +p<0.1, *p<0.05.) 
  nonumbers mtitles("Strong Concessions" " " "Political Concessions" " " "Num of Concessions" " " "Change in Demands" " " "Concessions/Demands" " ")  
  star(+ 0.1 * 0.05) ;
#delimit cr

	
	
*************************************
*************************************
*** Table A6: Additional Controls ***
*************************************
*************************************
tsset dyadid date
gen totaldeaths_month_thous=totaldeaths_monthtotal/1000

* Model 1 (Additional controls for conflict intensity)		
logit neg_DV ib0.battles_escalation weak_con_last_neg_dum str_centcomm parity groupnum dyad_months l.totaldeaths_month_thous l.count_state_success avg_battles_during_neg_nodecay c.t##c.t##c.t , cl(dyadid)
estimates store a18

* Model 2 (Additional conflict intensity controls & third-party involvement)
logit neg_DV ib0.battles_escalation##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months l.totaldeaths_month_thous l.count_state_success avg_battles_during_neg_nodecay c.t##c.t##c.t , cl(dyadid)
estimates store a19

* Model 3 (Additional group/conflict characteristic controls)	
logit neg_DV ib0.battles_escalation thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months territory reb_polwing rebelsupport_dum govsupport_dum dem_dummy_nona ib3.indirect_learning_4cat c.t##c.t##c.t , cl(dyadid)
estimates store a20

* Model 4 (Additional group/conflict characteristic controls & third-party involvement)	
logit neg_DV ib0.battles_escalation##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months territory reb_polwing rebelsupport_dum govsupport_dum dem_dummy_nona ib3.indirect_learning_4cat c.t##c.t##c.t , cl(dyadid)
estimates store a21

  
* Table A6 *
#delimit;
esttab a18 a19 a20 a21 using tableA6.rtf, replace
  stats(N) cells("b(star fmt(3))" se(par fmt(3))) 
  modelwidth(7) se label nogaps nonotes title(Table A6: Additional Control Variables) 
  addnote(Note: Standard errors, clustered on dyad ID, in parentheses. + p<0.1, * p<0.05.) 
  nonumbers mtitles("Model 1" "Model 2" "Model 3" "Model 4")  
  star(+ 0.1 * 0.05) ;
#delimit cr



*********************************************
*********************************************
*** Table A7: Alternative Model Selection ***
*********************************************
*********************************************

* Model 1 (rare events logit)
relogit neg_DV battles_escalation3 battles_escalation2 weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t t2 t3 , cl(dyadid)
estimates store a22

* Model 2 (rare events logit & third-party involvement)
relogit neg_DV battles_escalation3 battles_escalation2 thirdparty_involvement escalation_thirdparty_re nochange_thirdparty_re weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t t2 t3 , cl(dyadid)
estimates store a23

* Model 3 (Penalized ML)
firthlogit neg_DV ib0.battles_escalation weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t
estimates store a24

* Model 4 (Penalized ML & third-party involvement)
firthlogit neg_DV ib0.battles_escalation##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t 
estimates store a25

* Table A7 *
#delimit;
esttab a22 a23 a24 a25 using tableA7.rtf, replace
  stats(N) cells("b(star fmt(3))" se(par fmt(3))) 
  modelwidth(7) se label nogaps nonotes title(Table A7: Rare Event & Penalized ML Logistic Regression Results) 
  addnote(Note: Standard errors, clustered on dyad ID, in parentheses. + p<0.1, * p<0.05.) 
  nonumbers mtitles("Rare Event" "Rare Event" "Penalized ML" "Penalized ML")  
  star(+ 0.1 * 0.05) ;
#delimit cr
	


************************
************************
*** Table A8: Mlogit ***
************************
************************
use "BattlesBargains_ISQ_ReplicationData.dta", clear
set more off

* Model 1: using cat3_DV2 (0=none, 1=negotiation or settlement/ceasefire, 2=victory/low activity)
mlogit cat3_DV2 ib0.battles_escalation weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t, cl(dyadid)
estimates store a26
* Descriptives for text
tab cat3_DV2 if e(sample)

* Model 2: using cat3_DV2
mlogit cat3_DV2 ib0.battles_escalation##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t, cl(dyadid)
estimates store a27

* Table A8 *
#delimit;
esttab a26 a27 using tableA8.rtf, replace
  stats(N) cells("b(star fmt(3))" se(par fmt(3))) 
  modelwidth(7) se label nogaps nonotes title(Table A8: Multinomial Logistic Regression Results) 
  addnote(Note: Standard errors, clustered on dyad ID, in parentheses. + p<0.1, * p<0.05.) 
  nonumbers mtitles("Negotiations" "Settlement/Ceasefire" "Victory/Low Activity")  
  star(+ 0.1 * 0.05) ;
#delimit cr

* SI Footnote 4
mprobit cat3_DV2 ib0.battles_escalation weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t, cl(dyadid)
mprobit cat3_DV2 ib0.battles_escalation##i.thirdparty_involvement weak_con_last_neg_dum str_centcomm parity groupnum dyad_months c.t##c.t##c.t, cl(dyadid)



**************************************************
**************************************************
*** Figure A5: Baseline Hazard of Negotiations ***
**************************************************
**************************************************

* Figure A5a: Predicted Probabilities across Time Model 1 *
set seed 11235
estsimp logit neg_DV battles_escalation2 battles_escalation3 weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t t2 t3 , cl(dyadid)
gen plo=.
gen phi=.
gen pmean=.
gen timeaxis=_n+1 in 1/81
local a=2
while `a'<=82{
setx (t) `a' (t2) `a'^2 (t3) `a'^3
simqi, prval(1) genpr(neg_temp)
_pctile neg_temp, p(2.5, 50, 97.5)
replace plo=r(r1) if timeaxis==`a'
replace phi=r(r3) if timeaxis==`a'
replace pmean=r(r2) if timeaxis==`a'
drop neg_temp
local a= `a'+6
}
sort timeaxis
graph twoway (connected pmean timeaxis, lw(medium) lcolor(black) ms(point) title("Model 1") graphregion(color(white)) ///
     ytitle("Predicted Probability of Negotiations" " ") ///
     xtitle("Months Since Previous Negotiations Ended" " ") ///
     xtick(2(10)82) xlabel(2(10)82)  legend(off) ylabel(0(.1).53)) ///
	 (connected plo timeaxis, lw(thin) lcolor(gs10) ms(none)) ///
	 (connected phi timeaxis, lw(thin) lcolor(gs10) ms(none) saving(figureA5a.gph, replace))


  
* Figure A5b: Predicted Probabilities across Time Model 2 *
drop b1-b11
estsimp logit neg_DV battles_escalation3 battles_escalation2 thirdparty_involvement escalation_thirdparty_re nochange_thirdparty_re weak_con_last_neg_dum str_centcomm parity groupnum dyad_months t t2 t3 , cl(dyadid)
gen plo3=.
gen phi3=.
gen pmean3=.
gen timeaxis3=_n+1 in 1/81
local a=2
while `a'<=82{
setx (t) `a' (t2) `a'^2 (t3) `a'^3
simqi, prval(1) genpr(neg_temp)
_pctile neg_temp, p(2.5, 50, 97.5)
replace plo3=r(r1) if timeaxis3==`a'
replace phi3=r(r3) if timeaxis3==`a'
replace pmean3=r(r2) if timeaxis3==`a'
drop neg_temp
local a= `a'+6
}
sort timeaxis3
graph twoway (connected pmean3 timeaxis3, lw(medium) lcolor(black) ms(point) title("Model 2") graphregion(color(white)) ///
     ytitle(" ") ///
     xtitle("Months Since Previous Negotiations Ended" " ") ///
	 xtick(2(10)82) xlabel(2(10)82)  legend(off) ylabel(0(.1).53)) ///
	 (connected plo3 timeaxis3, lw(thin) lcolor(gs10) ms(none)) ///
	 (connected phi3 timeaxis3, lw(thin) lcolor(gs10) ms(none) saving(figureA5b.gph, replace))

#delimit;
graph combine figureA5a.gph figureA5b.gph ,
  col(3)
  title("Figure A5: Predicted Probability of Negotiations over Time", size(med))
  subtitle("", size(medsmall))
  graphregion(color(white))
  note("Note: 95% Confidence Intervals reported.", size(small)) 
  saving(figureA5.gph, replace)  ;
#delimit cr	 
	 
drop b1-b14 plo plo3 phi phi3 pmean pmean3 timeaxis timeaxis3
clear
